window.addEventListener('load',function(){
    var regtel=/^1[3 | 4 | 5| 7 | 8]\d{9}$/;
    var regduanxin=/^\d{6}$/;
    var regpwd=/^[a-zA-Z0-9-_]{6,16}$/;
    var tel=document.querySelector('.ipt-01');
    var duanxin=document.querySelector('.ipt-02');
    var pwd=document.querySelector('.ipt-03');
    var surepwd=document.querySelector('.ipt-04');
    //电话号码验证
    regexp(tel,regtel);
    //短信验证
    regexp(duanxin,regduanxin);
    // 密码验证
    regexp(pwd,regpwd);





    // 验证函数封装
    function regexp(ele,reg){
        ele.onblur=function(){
            if(reg.test(this.value)){
                // console.log('正确');
                this.nextElementSibling.className='success';
                this.nextElementSibling.innerHTML='<i class="success_icon"></i>您输入正确';
    
            }
            else{
                // console.log('错误');
                this.nextElementSibling.className='error';
                this.nextElementSibling.innerHTML='<i class="error_icon"></i>输入不正确，请重新输入';
            }
        }
    };

  surepwd.onblur=function(){
      if(this.value=pwd.value){
        this.nextElementSibling.className='success';
        this.nextElementSibling.innerHTML='<i class="success_icon"></i>您输入正确';
      }
      else{
        this.nextElementSibling.className='error';
        this.nextElementSibling.innerHTML='<i class="error_icon"></i>两次密码输入不正确';

      }
  }
})